home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-08-25 | 22.6 KB | 928 lines | [TEXT/CWIE] |
-
- #include <Gestalt.h>
- #include <LowMem.h>
- #include <Resources.h>
- #include <SCSI.h>
- #include <Script.h>
- #include <Start.h>
- #include <ToolUtils.h>
-
- #include "EditorUtilities.h"
-
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // Global Routines
- //
- /////////////////////////////////////////////////////////////////////////////////////////////////////
-
- /*—————————————————————————————————————————————— PStrCmp
- ————————————————————————————————————————————————————————————————————————————*/
- /*———— 0 if equal, <0 if p2<p1, >0 if p2>p1 ————*/
-
-
-
- SInt16 PStrCmp( ConstStr255Param p2, ConstStr255Param p1 )
- {
- SInt16 i;
- SInt16 len;
-
- if( (unsigned char)*p2 == (unsigned char)*p1 ) {
- len = (unsigned char)*p2;
- for( i=1; *p2 == *p1; p2++, p1++, i++ )
- if( i > len )
- return 0;
-
- return (unsigned char)*p2 - (unsigned char)*p1;
- }
- else
- return (unsigned char)*p2 - (unsigned char)*p1;
-
- }
-
-
- /*—————————————————————————————————————————————— PStrConcat
- ————————————————————————————————————————————————————————————————————————————*/
- /*———— dst = dst + src ————*/
-
- void PStrConcat( unsigned char* dst, const unsigned char* src )
- {
- SInt16 srcLen;
- SInt16 dstLen;
- unsigned char* ptr;
-
- srcLen = (unsigned char)*src;
- dstLen = (unsigned char)*dst;
-
- if( dstLen + srcLen > 255 )
- srcLen = 255 - dstLen;
-
- ptr = dst + dstLen;
-
- *dst = dstLen + srcLen;
- while (--srcLen>=0) *++ptr = *++src;
-
- }
-
- /*—————————————————————————————————————————————— pstrcpy
- ————————————————————————————————————————————————————————————————————————————*/
- /*———— copies a pascal string from p1 to p2 ————*/
- void PStrCopy( Str255 p2, ConstStr255Param p1 )
- {
- short len;
-
- *p2 = *p1++;
- len = (unsigned char)*p2++;
- while (--len>=0) *p2++=*p1++;
-
- }
-
-
-
- void GetIndStringWithParam( Str255 theString,
- SInt16 strListID,
- SInt16 index,
- ConstStr255Param pParamText0,
- ConstStr255Param pParamText1,
- ConstStr255Param pParamText2,
- ConstStr255Param pParamText3 )
- {
-
- Str255 tempStr255;
-
- // -- Get the string from our resource fork
- GetIndString( tempStr255, strListID, index );
-
- // -- Setup base string handle
- Handle baseStrHandle = NewHandle(tempStr255[0]);
- if( baseStrHandle )
- {
- BlockMove( &tempStr255[1], *baseStrHandle, tempStr255[0] );
-
- // -- Substitute ^0
- if( pParamText0[0] > 0 )
- {
- Handle subStrHandle = NewHandle(pParamText0[0]);
- if( baseStrHandle )
- {
- BlockMove( &pParamText0[1], *subStrHandle, pParamText0[0]);
- ReplaceText( baseStrHandle, subStrHandle, "\p^0" );
- DisposeHandle( subStrHandle );
- }
-
- }
-
- // -- Substitute ^1
- if( pParamText1[0] > 0 )
- {
- Handle subStrHandle = NewHandle(pParamText1[0]);
- if( baseStrHandle )
- {
- BlockMove( &pParamText1[1], *subStrHandle, pParamText1[0]);
- ReplaceText( baseStrHandle, subStrHandle, "\p^1" );
- DisposeHandle( subStrHandle );
- }
-
- }
-
- // -- Substitute ^2
- if( pParamText2[0] > 0 )
- {
- Handle subStrHandle = NewHandle(pParamText2[0]);
- if( baseStrHandle )
- {
- BlockMove( &pParamText2[1], *subStrHandle, pParamText2[0]);
- ReplaceText( baseStrHandle, subStrHandle, "\p^2" );
- DisposeHandle( subStrHandle );
- }
-
- }
-
- // -- Substitute ^3
- if( pParamText3[0] > 0 )
- {
- Handle subStrHandle = NewHandle(pParamText3[0]);
- if( baseStrHandle )
- {
- BlockMove( &pParamText3[1], *subStrHandle, pParamText3[0]);
- ReplaceText( baseStrHandle, subStrHandle, "\p^3" );
- DisposeHandle( subStrHandle );
- }
-
- }
-
- // Set the return string
- SInt32 baseStringLen = GetHandleSize( baseStrHandle );
- BlockMove( *baseStrHandle, &theString[1], baseStringLen );
-
- if( baseStringLen > 255 )
- theString[0] = 255;
- else
- theString[0] = baseStringLen;
-
-
- DisposeHandle( baseStrHandle );
- }
- else
- {
- theString[0] = 0;
- }
-
- }
-
- SInt16 GetUniqueIDForResType( SInt16 inFileRefNum, ResType theResType )
- {
- const SInt16 kLowerLimit = 10000;
- const SInt16 kUpperLimit = 20000;
-
- SInt16 savedResFile = CurResFile();
- UseResFile( inFileRefNum ) ;
-
- UInt16 hangPrevention = kLowerLimit;
- SInt16 theUniqueID = Unique1ID( theResType );
- while( (theUniqueID < kLowerLimit || theUniqueID > kUpperLimit) && hangPrevention < kUpperLimit )
- {
- theUniqueID = Unique1ID( theResType );
- hangPrevention++;
- }
-
- if( hangPrevention > kUpperLimit )
- theUniqueID = Unique1ID( theResType );
-
- UseResFile( savedResFile ) ;
-
- return theUniqueID;
- }
-
-
- void ResetResListResource( SInt16 inFileRefNum, SInt16 inResListRsrcID )
- {
-
- SInt16 savedResFile = CurResFile();
- UseResFile( inFileRefNum ) ;
-
- Handle theResListHandle = Get1Resource( 'RES#', inResListRsrcID );
-
- if( theResListHandle == NULL )
- {
- AddResource( NewHandle(2), 'RES#', inResListRsrcID, "\p" );
- FailResError();
- theResListHandle = Get1Resource( 'RES#', inResListRsrcID );
- FailNil( theResListHandle );
- }
- else
- {
- SetHandleSize( theResListHandle, 2 );
- FailMemError();
- }
-
- SInt16 tempShort = 0;
- BlockMove( &tempShort, *theResListHandle, 2 );
- ChangedResource( theResListHandle );
-
- UseResFile( savedResFile ) ;
- }
-
-
- void AppendToResListResource( SInt16 inFileRefNum, SInt16 inResListRsrcID, ResType inRsrcType, SInt16 inRsrcID )
- {
- if( inRsrcID != 0 ) // Don't add if rsrc ID is 0
- {
- SInt16 savedResFile = CurResFile();
- UseResFile( inFileRefNum ) ;
-
- Handle theResListHandle = Get1Resource( 'RES#', inResListRsrcID );
-
- if( theResListHandle != NULL )
- {
- PtrAndHand( &inRsrcType, theResListHandle, sizeof(ResType) );
- PtrAndHand( &inRsrcID, theResListHandle, 2 );
-
- SInt16 tempShort = 0;
- BlockMove( *theResListHandle, &tempShort, 2 );
- tempShort++;
- BlockMove( &tempShort, *theResListHandle, 2 );
-
- ChangedResource( theResListHandle );
- }
-
- UseResFile( savedResFile ) ;
- }
- }
-
-
- void DeleteResource( SInt16 inFileRefNum, ResType inRsrcType, SInt16 inRsrcID )
- {
- if( inRsrcID != 0 ) // Don't try deleting if rsrc ID is 0
- {
- SInt16 savedResFile = CurResFile();
- UseResFile( inFileRefNum ) ;
-
- Handle theRsrcHandle = Get1Resource( inRsrcType, inRsrcID );
-
- if( theRsrcHandle != NULL )
- {
- RemoveResource( theRsrcHandle );
- DisposeHandle( theRsrcHandle );
-
- }
-
- UseResFile( savedResFile ) ;
- }
- }
-
-
- void WriteStringResource( SInt16 inRsrcID, Str255 inString )
- {
- StringHandle theStrHandle = GetString( inRsrcID );
-
- if( theStrHandle == NULL )
- {
- AddResource( (Handle)NewString( inString ), 'STR ', inRsrcID, "\p" );
- FailResError();
- }
- else
- {
- SetHandleSize( (Handle)theStrHandle, inString[0] + 1 );
- FailMemError();
- BlockMove( &inString[0], *theStrHandle, inString[0] + 1 );
- ChangedResource( (Handle)theStrHandle );
- }
-
- }
-
- void WriteStringListResourceIndex( SInt16 inFileRefNum, Str255 inString, SInt16 inRsrcID, SInt16 inIndex )
- {
- SInt16 savedResFile = CurResFile();
- UseResFile( inFileRefNum );
-
- UInt16 totalNumOfItems = inIndex;
-
- Handle theOrgStrListHandle = Get1Resource( 'STR#', inRsrcID );
- if( theOrgStrListHandle && **((UInt16**)theOrgStrListHandle) > totalNumOfItems )
- totalNumOfItems = **((UInt16**)theOrgStrListHandle);
-
- TRsrcHandle* theRsrcStream = new TRsrcHandle;
- SignalIf_(theRsrcStream == nil);
-
- theRsrcStream->AppendShort( totalNumOfItems );
-
- Str255 tempStr;
- for( UInt16 i = 1; i <= totalNumOfItems; i++ )
- {
- GetIndString( tempStr, inRsrcID, i );
-
- if( i == inIndex )
- theRsrcStream->AppendStr255WithoutPadByte( inString );
- else
- theRsrcStream->AppendStr255WithoutPadByte( tempStr );
- }
-
- theRsrcStream->Write( inFileRefNum, 'STR#', inRsrcID );
-
- delete theRsrcStream;
-
- UseResFile( savedResFile );
-
- }
-
-
- OSErr GetFileNameFromFileRefID( SInt16 inFileRefID, Str255 outFileName )
- {
- const ResType kFileRefRsrcType = 'flrf';
-
- OSErr theErr = noErr;
-
- try
- {
- outFileName[0] = 0;
-
- // Get File Ref Resource
- Handle theFileRefRsrcHandle = GetResource( kFileRefRsrcType, inFileRefID );
- if( theFileRefRsrcHandle )
- {
-
- // Create TRsrcHandleObj from file ref resource.
- TRsrcHandle* theFileRef = new TRsrcHandle( theFileRefRsrcHandle );
- FailNil( theFileRef );
-
- // Get fields from resource
- if( theFileRef->ReadShort() == 0 ) // Skip format number.
- {
- theFileRef->ReadShort(); // Skip unused flags.
- theFileRef->ReadShort(); // Skip media type.
- theFileRef->ReadLong(); // Skip file type.
- theFileRef->ReadLong(); // Skip file creator.
- theFileRef->ReadLong(); // Skip file creation date.
- theFileRef->ReadPStrIntoStr255( outFileName ); // using outFileName as temp var to read path
- theFileRef->ReadPStrIntoStr255( outFileName ); // read file name into var to return
- }
- else
- theErr = fnfErr;
-
- delete theFileRef;
- }
- else
- theErr = fnfErr;
-
- }
- catch( OSErr catchErr )
- {
- theErr = catchErr;
- }
-
- return theErr;
- }
-
-
- EKeyStatus PrintingCharWithReturnField(const EventRecord &inKeyEvent)
- {
-
- EKeyStatus theKeyStatus = keyStatus_PassUp;
- Char16 theKey = inKeyEvent.message;
- Char16 theChar = theKey & charCodeMask;
-
- if (UKeyFilters::IsTEDeleteKey(theKey)) {
- theKeyStatus = keyStatus_TEDelete;
- } else if (UKeyFilters::IsTECursorKey(theKey)) {
- theKeyStatus = keyStatus_TECursor;
- } else if (UKeyFilters::IsExtraEditKey(theKey)) {
- theKeyStatus = keyStatus_ExtraEdit;
- } else if (UKeyFilters::IsPrintingChar(theChar)) {
- theKeyStatus = keyStatus_Input;
- } else if (theChar == 0x0D )
- theKeyStatus = keyStatus_Input;
-
- return theKeyStatus;
-
- }
-
-
- EKeyStatus SignedIntegerField(const EventRecord &inKeyEvent)
- {
- EKeyStatus theKeyStatus = keyStatus_PassUp;
- Char16 theKey = inKeyEvent.message;
- Char16 theChar = theKey & charCodeMask;
-
- if (UKeyFilters::IsTEDeleteKey(theKey)) {
- theKeyStatus = keyStatus_TEDelete;
- } else if (UKeyFilters::IsTECursorKey(theKey)) {
- theKeyStatus = keyStatus_TECursor;
- } else if (UKeyFilters::IsExtraEditKey(theKey)) {
- theKeyStatus = keyStatus_ExtraEdit;
- } else if (UKeyFilters::IsPrintingChar(theChar)) {
- if (UKeyFilters::IsNumberChar(theChar)) {
- theKeyStatus = keyStatus_Input;
- } else if (theChar == '-' ) {
- theKeyStatus = keyStatus_Input;
- } else {
- theKeyStatus = keyStatus_Reject;
- }
- }
-
- return theKeyStatus;
- }
-
-
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // class TRsrcHandle - class for reading and writing complex structured resources
- //
- /////////////////////////////////////////////////////////////////////////////////////////////////////
-
- // ---------------------- • TRsrcHandle -----------------------------------
- TRsrcHandle::TRsrcHandle()
- {
- fRsrcHandle = NewHandle( 0 );
- FailMemError();
- SetPos( 1 );
- }
-
- // ---------------------- • TRsrcHandle -----------------------------------
- TRsrcHandle::TRsrcHandle( Handle pInitilizedHandle )
- {
- if( pInitilizedHandle == NULL )
- {
- fRsrcHandle = NewHandle( 0 );
- FailMemError();
- }
- else {
- fRsrcHandle = pInitilizedHandle;
- FailErr( HandToHand( &fRsrcHandle ) );
- }
- SetPos( 1 );
- }
-
- // ---------------------- • TRsrcHandle -----------------------------------
- TRsrcHandle::TRsrcHandle( Ptr pInitilizedPtr )
- {
- if( pInitilizedPtr == NULL )
- {
- fRsrcHandle = NewHandle( GetPtrSize(pInitilizedPtr) );
- FailMemError();
-
- PtrToHand( pInitilizedPtr, &fRsrcHandle, GetPtrSize(pInitilizedPtr) );
- }
- SetPos( 1 );
- }
-
-
- // ---------------------- • ~TRsrcHandle -----------------------------------
- TRsrcHandle::~TRsrcHandle()
- {
- DetachResource( fRsrcHandle ); // In case it's a rsrc handle
- DisposeHandle( fRsrcHandle );
- }
-
-
- // ---------------------- • AppendLong -----------------------------------
- void TRsrcHandle::AppendLong( SInt32 pTheLong )
- {
- Handle longHandle = NewHandle( sizeof( SInt32 ) );
- FailMemError();
- (**(SInt32**)longHandle) = pTheLong;
-
- HLock(longHandle);
- FailErr( HandAndHand( longHandle, fRsrcHandle ) );
- DisposeHandle( longHandle );
- }
-
-
- // ---------------------- • AppendShort -----------------------------------
- void TRsrcHandle::AppendShort( SInt16 pTheShort )
- {
- Handle shortHandle = NewHandle( 2 );
- FailMemError();
- (**(SInt16**)shortHandle) = pTheShort;
-
- HLock(shortHandle);
- FailErr( HandAndHand( shortHandle, fRsrcHandle ) );
- DisposeHandle( shortHandle );
- }
-
-
- // ---------------------- • AppendStr255WithoutPadByte -----------------------------------
- void TRsrcHandle::AppendStr255WithoutPadByte( Str255 pTheStr255 )
- {
- char *curCharPtr;
- SInt16 lenToCreate = pTheStr255[0] + 1;
-
- Handle tempHandle;
-
- tempHandle = NewHandle( lenToCreate );
- FailMemError();
- HLock(tempHandle);
- curCharPtr = *tempHandle;
-
- // copy the Str255 into the handle
- for(SInt16 i=0; i<=pTheStr255[0]; i++, curCharPtr++)
- (*curCharPtr) = pTheStr255[i];
-
- FailErr( HandAndHand( tempHandle, fRsrcHandle ) );
- DisposeHandle( tempHandle );
- }
-
- // ---------------------- • AppendStr255 -----------------------------------
- void TRsrcHandle::AppendStr255( Str255 pTheStr255 )
- {
- char *curCharPtr;
- SInt16 lenToCreate = pTheStr255[0] + 1;
- Boolean pad1Byte = false;
-
- Handle tempHandle;
-
- // If the length we’re creating is odd, we bump the length by 1 to do word aligned strings
- if( ( lenToCreate % 2 ) != 0 ) {
- lenToCreate++;
- pad1Byte = true;
- }
-
- tempHandle = NewHandle( lenToCreate );
- FailMemError();
- HLock(tempHandle);
- curCharPtr = *tempHandle;
-
- // copy the Str255 into the handle
- for(SInt16 i=0; i<=pTheStr255[0]; i++, curCharPtr++)
- (*curCharPtr) = pTheStr255[i];
-
- // fill out the pad byte if necessary
- if( pad1Byte )
- (*curCharPtr) = '\0';
-
- FailErr( HandAndHand( tempHandle, fRsrcHandle ) );
- DisposeHandle( tempHandle );
- }
-
- // ---------------------- • AppendStr255AsData -----------------------------------
- void TRsrcHandle::AppendStr255AsData( Str255 pTheStr255 )
- {
- // -- Adds the Str255 without the length byte. Good for adding Str255 variables to
- // windows or data forks.
- char *curCharPtr;
- Handle tempHandle = NewHandle( pTheStr255[0] );
- FailMemError();
- HLock(tempHandle);
- curCharPtr = *tempHandle;
- for(SInt16 i=1; i<=pTheStr255[0]; i++, curCharPtr++)
- (*curCharPtr) = pTheStr255[i];
- FailErr( HandAndHand( tempHandle, fRsrcHandle ) );
- DisposeHandle( tempHandle );
- }
-
-
- // ---------------------- • AppendHandle -----------------------------------
- void TRsrcHandle::AppendHandle( Handle pTheHandle )
- {
- SignedByte lastHandleState = HGetState(pTheHandle);
- HLock(pTheHandle);
- FailErr( HandAndHand( pTheHandle, fRsrcHandle ) );
- HSetState(pTheHandle, lastHandleState);
- }
- /*
- // ---------------------- • AppendStr255FromHandle -----------------------------------
- void TRsrcHandle::AppendStr255FromHandle( Handle pTheHandle )
- {
- AppendStr255( BKMakeStr255FromHandle( pTheHandle ) );
- }
- */
-
- // ---------------------- • Write -----------------------------------
- void TRsrcHandle::Write( SInt16 pFileRefNum,
- OSType pRsrcType,
- SInt16 pRsrcID )
- {
- Handle tempHandle;
- SInt16 savedResFile = CurResFile();
- UseResFile( pFileRefNum );
-
- tempHandle = Get1Resource( pRsrcType, pRsrcID );
- if( tempHandle ) {
- RemoveResource( tempHandle );
- DisposeHandle( tempHandle );
- }
- FailResError();
- AddResource( fRsrcHandle, pRsrcType, pRsrcID, "\p" );
- FailResError();
-
- UpdateResFile( pFileRefNum );
-
- DetachResource( fRsrcHandle );
-
- UseResFile( savedResFile );
- }
-
- // ---------------------- • ReadByteIntoShort -----------------------------------
- SInt16 TRsrcHandle::ReadByteIntoShort()
- {
- UInt16 tempShort = 0;
-
- ReadChunk( (Ptr)&tempShort, 1 );
- tempShort >>= 8;
-
- return (SInt16)tempShort;
- }
-
-
- // ---------------------- • ReadLong -----------------------------------
- SInt32 TRsrcHandle::ReadLong()
- {
- SInt32 tempLong = 0;
-
- ReadChunk( (Ptr)&tempLong, sizeof( SInt32 ) );
-
- return tempLong;
- }
-
- // ---------------------- • ReadShort -----------------------------------
- SInt16 TRsrcHandle::ReadShort()
- {
- SInt16 tempShort = 0;
-
- ReadChunk( (Ptr)&tempShort, 2 );
-
- return tempShort;
- }
-
-
- // ---------------------- • ReadPStrIntoHandle -----------------------------------
- Handle TRsrcHandle::ReadPStrIntoHandle()
- {
- SInt16 stringLen = ReadByteIntoShort() ;
- Handle tempHandle = NewHandle( stringLen);
- if( tempHandle != NULL )
- ReadChunk( *tempHandle, stringLen );
-
- // If the length we’re reading is odd, we need to read one more byte.
- if( ( stringLen % 2 ) == 0 )
- ReadByteIntoShort();
-
- return tempHandle;
- }
-
-
- // ---------------------- • ReadPStrIntoStr255 -----------------------------------
- void TRsrcHandle::ReadPStrIntoStr255( Str255 outStr255 )
- {
- SInt16 stringLen = ReadByteIntoShort();
-
- ReadChunk( (Ptr)&(outStr255[1]), stringLen );
-
- // If the length we’re reading is odd, we need to read one more byte.
- if( ( stringLen % 2 ) == 0 )
- ReadByteIntoShort();
-
- outStr255[0] = stringLen;
- }
-
- // ---------------------- • ReadChunk -----------------------------------
- void TRsrcHandle::ReadChunk(Ptr pDest,
- SInt32 pSize )
- {
- // ReadChunk from the Installer.
-
- Ptr theSrc = StripAddress( *fRsrcHandle ) + fCurPos - 1;
- BlockMove( theSrc, pDest, pSize );
- fCurPos += pSize;
- }
-
-
-
-
- /*
- void VersionNumToString( UInt32 inVersionNum, Str255 outFormattedStr )
- {
- #define kMajorVersMask 0xFF000000
- #define kMinorVersMask 0x00F00000
- #define kBugFixVersMask 0x000F0000
- #define kStageVersMask 0x0000FF00
- #define kReleaseVersMask 0x000000FF
-
- #define kMajorVersShift 24
- #define kMinorVersShift 20
- #define kBugFixVersShift 16
- #define kStageVersShift 8
- #define kReleaseVersShift 0
-
- #define kDevel 0x20
- #define kAlpha 0x40
- #define kBeta 0x60
- #define kFinal 0x80
-
- unsigned long majorVersValue;
- unsigned long minorVersValue;
- unsigned long bufFixVersValue;
- unsigned long stageVersValue;
- unsigned long releaseVersValue;
- Str255 tempVersStr;
-
- outFormattedStr[0] = 0;
-
- if( inVersionNum < 0x0000FFFF && inVersionNum > 0 ) {
-
- // —— Handle old style
-
- majorVersValue = inVersionNum / 100;
- NumToString( majorVersValue, tempVersStr );
- PStrConcat( outFormattedStr, tempVersStr );
-
- minorVersValue = inVersionNum / 10 - majorVersValue * 10;
- NumToString( minorVersValue, tempVersStr );
- PStrConcat( outFormattedStr, "\p." );
- PStrConcat( outFormattedStr, tempVersStr );
-
- bufFixVersValue = inVersionNum - majorVersValue * 100 - minorVersValue * 10;
-
- if( bufFixVersValue != 0 ) {
- NumToString( bufFixVersValue, tempVersStr );
- PStrConcat( outFormattedStr, "\p." );
- PStrConcat( outFormattedStr, tempVersStr );
- }
- }
- else {
-
- // —— Handle standard version number format with build stage and release
-
- majorVersValue = (inVersionNum & kMajorVersMask) >> kMajorVersShift;
- NumToString( majorVersValue, tempVersStr );
- PStrConcat( outFormattedStr, tempVersStr );
-
- minorVersValue = (inVersionNum & kMinorVersMask) >> kMinorVersShift;
- NumToString( minorVersValue, tempVersStr );
- PStrConcat( outFormattedStr, "\p." );
- PStrConcat( outFormattedStr, tempVersStr );
-
- bufFixVersValue = (inVersionNum & kBugFixVersMask) >> kBugFixVersShift;
- if( bufFixVersValue != 0 ) {
- NumToString( bufFixVersValue, tempVersStr );
- PStrConcat( outFormattedStr, "\p." );
- PStrConcat( outFormattedStr, tempVersStr );
- }
-
- stageVersValue = (inVersionNum & kStageVersMask) >> kStageVersShift;
- releaseVersValue = (inVersionNum & kReleaseVersMask) >> kReleaseVersShift;
-
- if( releaseVersValue != 0 ) {
-
- switch( stageVersValue ) {
- case kDevel:
- PStrConcat( outFormattedStr, "\pd" );
- break;
- case kAlpha:
- PStrConcat( outFormattedStr, "\pa" );
- break;
- case kBeta:
- PStrConcat( outFormattedStr, "\pb" );
- break;
- case kFinal:
- PStrConcat( outFormattedStr, "\pf" );
- break;
- }
-
- NumToString( releaseVersValue, tempVersStr );
- PStrConcat( outFormattedStr, tempVersStr );
-
- }
- }
-
- }
-
-
- void NumToCommaString( SInt32 pLongNum,
- Str255 pOutputStr )
- {
-
- Str255 theCommaString;
-
- if( pLongNum == 0 )
- {
-
- GetIndString( pOutputStr, kUtilityStringsSTRListRsrcID, kZeroStringIndex );
- }
- else
- {
- NumToString( pLongNum, pOutputStr );
-
- GetIndString( theCommaString, kUtilityStringsSTRListRsrcID, kCommaStringIndex );
-
- if( pOutputStr[0] > 6 )
- {
- BlockMove( (Ptr)pOutputStr + pOutputStr[0] - 5, (Ptr)pOutputStr + pOutputStr[0] - 5 + theCommaString[0], 6 );
- BlockMove( (Ptr)&theCommaString[1], (Ptr)pOutputStr + pOutputStr[0] - 5, theCommaString[0] );
- pOutputStr[0] += theCommaString[0];
- }
-
- if( pOutputStr[0] > 3 )
- {
- BlockMove( (Ptr)pOutputStr + pOutputStr[0] - 2, (Ptr)pOutputStr + pOutputStr[0] - 2 + theCommaString[0], 3 );
- BlockMove( (Ptr)&theCommaString[1], (Ptr)pOutputStr + pOutputStr[0] - 2, theCommaString[0] );
- pOutputStr[0] += theCommaString[0];
- }
- }
-
- }
- */
-
-
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // Class LShortComparator
- //
- // Compares items as Short integer values
- //
- /////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
- LShortComparator* LShortComparator::sShortComparator;
-
- Int32
- LShortComparator::Compare(
- const void* inItemOne,
- const void* inItemTwo,
- Uint32 /* inSizeOne */,
- Uint32 /* inSizeTwo */) const
- {
- return ( (*(SInt16*) inItemOne) - (*(SInt16*) inItemTwo) );
- }
-
-
- Boolean
- LShortComparator::IsEqualTo(
- const void* inItemOne,
- const void* inItemTwo,
- Uint32 /* inSizeOne */,
- Uint32 /* inSizeTwo */) const
- {
- return ( (*(SInt16*) inItemOne) == (*(SInt16*) inItemTwo) );
- }
-
-
- LShortComparator*
- LShortComparator::GetComparator()
- {
- if (sShortComparator == nil) {
- sShortComparator = new LShortComparator;
- }
-
- return sShortComparator;
- }
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // Class LResTypeAndIDComparator
- //
- // Compares items as Short integer values
- //
- /////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-
- LResTypeAndIDComparator* LResTypeAndIDComparator::sResTypeAndIDComparator;
-
- Int32
- LResTypeAndIDComparator::Compare(
- const void* inItemOne,
- const void* inItemTwo,
- Uint32 /* inSizeOne */,
- Uint32 /* inSizeTwo */) const
- {
-
- Int32 resTypeResult = (((RsrcTypeAndID*)inItemOne)->fRsrcType) - (((RsrcTypeAndID*)inItemTwo)->fRsrcType);
- Int32 IDResult = (((RsrcTypeAndID*)inItemOne)->fRsrcID) - (((RsrcTypeAndID*)inItemTwo)->fRsrcID);
-
- if( resTypeResult )
- return resTypeResult;
- else
- return IDResult;
- }
-
-
- Boolean
- LResTypeAndIDComparator::IsEqualTo(
- const void* inItemOne,
- const void* inItemTwo,
- Uint32 /* inSizeOne */,
- Uint32 /* inSizeTwo */) const
- {
- Boolean resTypeResult = (((RsrcTypeAndID*)inItemOne)->fRsrcType) == (((RsrcTypeAndID*)inItemTwo)->fRsrcType);
- Boolean IDResult = (((RsrcTypeAndID*)inItemOne)->fRsrcID) == (((RsrcTypeAndID*)inItemTwo)->fRsrcID);
-
- return resTypeResult && IDResult;
- }
-
-
- LResTypeAndIDComparator*
- LResTypeAndIDComparator::GetComparator()
- {
- if (sResTypeAndIDComparator == nil) {
- sResTypeAndIDComparator = new LResTypeAndIDComparator;
- }
-
- return sResTypeAndIDComparator;
-
-
- }
-
-